﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="FileManager.aspx.cs" Inherits="Admin_Form_FileManager" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadCodeBlock ID="codeBlock1" runat="server">
        <script type="text/javascript">
            //<![CDATA[
            function OnClientItemSelected(sender, args) {
                var pvwImage = $get("<%= pvwImage.ClientID %>");
                var imageSrc = args.get_path();
                if (imageSrc.match(/\.(gif|jpg|png|jpeg)$/gi)) {
                    pvwImage.src = imageSrc;
                    pvwImage.style.display = "";
                    document.getElementById("imageSrc").value = imageSrc
                }else if(!imageSrc.match(/\./gi))     {
                    pvwImage.src = imageSrc + "/";
                    pvwImage.style.display = "";
                    document.getElementById("imageSrc").value = imageSrc
                }
                else {
                    pvwImage.src = imageSrc;
                    pvwImage.style.display = "none";
                }
                
            }

            function chooseImage() {
                var win = window.parent;
                win.document.getElementById($get("<%= returnBox.ClientID %>").value).value = this.document.getElementById("imageSrc").value;
                alert('Ban da chon file thanh cong!');
                window.close();
            }
            //]]>
        </script>
    </telerik:RadCodeBlock>
    
    
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    
    <input type="hidden" id="imageSrc" />
    <input type="hidden" runat="server" id="returnBox" />
    <table>
        <tr>
            <td>
                <div>
                    <telerik:RadFileExplorer ID="RadFileExplorer1" runat="server" OnClientItemSelected="OnClientItemSelected">
                        <Configuration ViewPaths="/Upload"
                            UploadPaths="/Upload" DeletePaths="/Upload" MaxUploadFileSize="200000" />
                    </telerik:RadFileExplorer>
                </div>
            </td>
            <td valign="top">
                <fieldset style="border:solid 1px #ccc" style="width: 230px; height: 220px">
                    <legend>Preview</legend>
                    <img id="pvwImage" runat="server" alt="" style="display: none;
                        margin: 10px; width: 200px; height: 180px; vertical-align: middle;" />
                </fieldset>
                <br/>
                <asp:Button runat="server" Text="Chọn" ID="btnSubmit" OnClientClick="chooseImage(); return false;"/>
            </td>
        </tr>
    </table>
    
    
    
    </form>
</body>
</html>
